using micromsg;
using MicroMsg.Common.Event;
using MicroMsg.Common.Utils;
using MicroMsg.Manager;
using MicroMsg.Protocol;
using MicroMsg.Scene;
using MicroMsg.Storage;
using System;
using System.Collections.Generic;
namespace MicroMsg.Plugin.Sns.Scene
{
	public class NetSceneSnsTagMemberOption : NetSceneBaseEx<SnsTagMemberOptionRequest, SnsTagMemberOptionResponse, SnsTagMemberOptionRequest.Builder>
	{
		private const string TAG = "NetSceneSnsTagMemberOption";
		private static NetSceneSnsTagMemberOption _mInstance;
		public static NetSceneSnsTagMemberOption Instance
		{
			get
			{
				if (NetSceneSnsTagMemberOption._mInstance == null)
				{
					NetSceneSnsTagMemberOption._mInstance = new NetSceneSnsTagMemberOption();
				}
				return NetSceneSnsTagMemberOption._mInstance;
			}
		}
		public bool doScene(SnsTagMemOptionOpCode opCode, ulong tagId, string tagName, List<string> userNameList)
		{
			base.beginBuilder();
			this.mBuilder.BaseRequest = NetSceneBase.makeBaseRequest(0);
			this.mBuilder.OpCode = (uint)opCode;
			this.mBuilder.TagId = tagId;
			this.mBuilder.TagName = tagName;
			using (List<string>.Enumerator enumerator = userNameList.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					string current = enumerator.get_Current();
					this.mBuilder.ListList.Add(Util.toSKString(current));
				}
			}
			this.mBuilder.Count = (uint)this.mBuilder.ListList.get_Count();
			this.mSessionPack.mCmdID = 115;
			return base.endBuilder();
		}
		protected override void onFailed(SnsTagMemberOptionRequest request, SnsTagMemberOptionResponse response)
		{
			Log.smethod_1("NetSceneSnsTagMemberOption", "send request failed");
			EventCenter.postEvent(EventConst.ON_NETSCENE_SNS_TAG_MEMBER_OP_ERR, request.TagId, null);
		}
		protected override void onSuccess(SnsTagMemberOptionRequest request, SnsTagMemberOptionResponse response)
		{
			RetConst ret = (RetConst)response.BaseResponse.Ret;
			if (ret != RetConst.MM_OK)
			{
				EventCenter.postEvent(EventConst.ON_NETSCENE_SNS_TAG_MEMBER_OP_ERR, response.SnsTag.TagId, null);
				return;
			}
			SnsTagInfo item = SnsInfoMgr.toSnsTagInfo(response.SnsTag);
			StorageMgr.snsTag.update(item);
			EventCenter.postEvent(EventConst.ON_NETSCENE_SNS_TAG_MEMBER_OP_SUCCESS, response.SnsTag.TagId, null);
		}
	}
}
